import axios from "../request.use";

// 请求类（ 登录相关 ）
class PublicApiClass {
  // 登录接口
  longinByPhone({code, encryptedData, iv}) {
    return axios.request({
			url: '/weixin/login',
			method: 'post',
			data: {code, encrypted_data: encryptedData, iv}
		})
  }
	// 注册账号
	sendPhoneCode(query) {
		return axios.request({
			url: '/common/sendSmsCode',
			method: 'get',
			data: query
		})
	}

  // 获取用户签到状态
  uploadFile(query) {
    console.log("query === ", query);
    return axios.request({
      url: "file/upload",
      method: "post",
      data: query,
      header: {
        "Content-Type": "multipart/form-data",
      },
    });
  }

  // 获取验证码
  getPhoneCode(query) {
    return axios.request({
      url: "sms/send",
      method: "post",
      data: query,
    });
  }

  // 验证验证码
  rePhoneCode(query) {
    return axios.request({
      url: "sms/verify",
      method: "post",
      data: query,
    });
  }

  // 行业列表
  getIndustryList() {
    return axios.request({
      url: "industry/list",
      method: "get",
    });
  }

  // 地区列表
  getAreaList() {
    return axios.request({
      url: "area/list",
      method: "get",
    });
  }

  //上传文件
  uploadFile(query) {
    return new Promise((resolve, reject) => {
      wx.uploadFile({
        url: "https://test.biaoziku.com/res/file/upload", // 替换为实际的上传接口地址
        filePath: query.filePath,
        name: "fileVal",
        formData: query.formData,
        header: {
          "Content-Type": "multipart/form-data",
        },
        success: function (uploadRes) {
          resolve(JSON.parse(uploadRes.data))
        },
        fail: function (err) {
          reject(err)
        },
      });
    });
  }
}

const publicApi = new PublicApiClass();

export { publicApi };
